package com.example.skilltest.controller;

import com.example.skilltest.entity.Employee;
import com.example.skilltest.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

@RestController
public class EmpController {

    @Autowired
    EmployeeService employeeService;

    @GetMapping("/emp")
    public Employee getEmpById(@RequestParam("id") int id) {
        return employeeService.getEmpById(id);
    }

    @GetMapping("/allemp")
    public List<Employee> getAll() {
        return employeeService.getEmpListByIds();
    }

    public static void main(String[] args) {
        LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime tomorrowStart = todayStart.plusDays(1);
        LocalDateTime twoTomorrowStart = todayStart.plusDays(2);
        System.out.println("今天："+todayStart);
        System.out.println("明天："+tomorrowStart);
        System.out.println("后天："+twoTomorrowStart);
        System.out.println("=========================================");
        if(todayStart.isBefore(tomorrowStart)){
            System.out.println("今天在明天之前");
        }
        if (tomorrowStart.isAfter(todayStart)){
            System.out.println("明天在今天之后");
        }
        if (tomorrowStart.isAfter(todayStart) && tomorrowStart.isBefore(twoTomorrowStart)){
            System.out.println("明天在今天之后，明天在后之前，明天在今天和后天两者之间");
        }


    }
}
